package com.cy.java.util;

import java.lang.reflect.Constructor;

public class ReflectUtil {
    /**
     * 基于传入的类型构建对象的实例
     */
    public static Object newInstance(String pkgClass, Object[] args, Class<?>... parameterTypes) throws Exception {
        Class cls = Class.forName(pkgClass);
        Constructor c = cls.getDeclaredConstructor(parameterTypes);
        c.setAccessible(true);
        return c.newInstance(args);
    }
}
